<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<jsp:useBean id="now" class="java.util.Date"></jsp:useBean>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-3.3.1.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/addschedule.css">
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/jquery.datetimepicker.css">
	<script src="${pageContext.request.contextPath }/static/js/jquery.datetimepicker.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/ion.calendar.css">
	<script src="${pageContext.request.contextPath }/static/js/moment.min.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/moment.zh-cn.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/ion.calendar.min.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/demo1.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/avgrund.css">
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/avgrund.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/nav.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/demo9.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/menu_sideslide.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/normalize.css" />
	<script type="text/javascript">
		$(function(){
			
		
		$(".start_date").datetimepicker({
            lang:'ch',
            format:'Y-m-d',
            formatDate:'Y-m-d',
            timepicker:false
        });
        $(".end_date").datetimepicker({
            lang:'ch',
            format:'Y-m-d',
            formatDate:'Y-m-d',
            timepicker:false
        });
		});

        $(function(){
            $("#calendar").ionCalendar({
                lang: 'zh-cn',
                format: 'YYYY年M月D日',
                onClick: function(date){
                	var code = "<%=request.getParameter("code")%>";
                	
                	if(code==1){
                	var time=new Date(Date.parse(date.replace('年','-').replace('月','-').replace('日','')))
                    console.log(time)
                    var d=new Date(time);
                    var year=d.getFullYear();
                    var month=change(d.getMonth()+1);
                    var day=change(d.getDate());
                    var time=year+'-'+month+'-'+day;
                    
                    /* alert(time); */
                    openDialog();
                    function change(t){
                        if(t<10){
                            return "0"+t;
                        }else{
                            return t;
                        }
                    }
                    var user="<%=request.getParameter("user")%>"
                    var param_data={
                    	'user':user,
                    	'start_date':time
                    }
                   /*  alert(user); */
                    $.ajax({
                    	type:"POST",
                        url:"${pageContext.request.contextPath }/selectSchedule.action",
                        data:{'param':JSON.stringify(param_data)},
                        dataType:"json",
                        async:false,
                        success:function(data){
                        	console.log(data)
                            if(data != ""){
           						var tbl=""
           						
           						var text3="edit_sch"
                       		 	for(var i=0;i<data.length;i++){
                       		 	var text1="${pageContext.request.contextPath }/deleteSchedule.action?id="+data[i].id
               					var text2="${pageContext.request.contextPath }/SelectOne.action?id="+data[i].id
                       			 tbl+="<p><span>主题</span>：<span>"+data[i].theme+"</span></p><p><span>开始时间</span>：<span>"+data[i].start_date+" "+data[i].start_time+"</span></p><p><span>结束时间</span>：<span>"+data[i].end_date+" "+data[i].end_time+"</span></p><p><span>人员</span>：<span>"+data[i].staff+"</span></p><p><span>说明</span>：<span>"+data[i].instruction +"</span></p>"+"<p><a href='"+text1+"'>删除</a>"+"<a href='"+text2+"' class='"+text3+"'>修改</a></p>"
                       		}  		    	
                 		     $(".detail_content").html(tbl);
                            }else{       
                            	$(".detail_content").html("您没有添加事件");
                            }
                        }
                    });
                }else{
                	alert("您还未登录！");
                }
                }
            
            });
            $(function () {
				$(".ul1").find("li").eq(0).click(function () {
					var code = "<%=request.getParameter("code")%>";
					
					
					if(code==1 ){
						location.href="main.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					}
					
                });
				$(".ul1").find("li").eq(1).click(function () {
					var code = "<%=request.getParameter("code")%>";
					
					if(code==1){
						location.href="../../jsp/schedule.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					}
					
                });
				$(".ul1").find("li").eq(2).click(function () {
					var code = "<%=request.getParameter("code")%>";
					
					if(code==1){
						location.href="../../jsp/backtime.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					}
					
                });

	           $("#rob").click(function () {	
					var code = "<%=request.getParameter("code")%>";
					if(code==1){
 						location.href="../../jsp/robot.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";

					}
					else{
						alert("您还未登录！");
					} 					
                });													
				
            });
        });


	</script>
	<script type="text/javascript">

        function openDialog() {
            Avgrund.show( "#default-popup" );
        }

        function closeDialog() {
            Avgrund.hide();
        }

	</script>
	<script type="text/javascript">
	$(function () {
		$(".button_warn").click(function () {
			var code = "<%=request.getParameter("code")%>";
			
			if(code==1 ){
			$(".right_warn").animate({width:'toggle'},300);
			}
			else{
				alert("您还未登录！");
			}
        });
    });
	$(function(){
		 function show(){
	           var mydate = new Date();
	           var str = "" + mydate.getFullYear() + "-";
	           str += (mydate.getMonth()+1) + "-";
	           str += mydate.getDate();
	           return str;
	       }
		 var date=show()
		 console.log(date);
		 var user="<%=request.getParameter("user")%>";
		 if(user == ""){
			 return;
		 }else{
		 var param_data1={
				 'start_date':date,
		 		 'warn':'提醒',
		 		 'user':user
		 }
		 $.ajax({
			 type:"POST",
             url:"${pageContext.request.contextPath }/SelectScheduleByWarn.action",
             data:{'param':JSON.stringify(param_data1)},
             dataType:"json",
             async:false,
             success:function(data){
            	var tbl=""
            	if(data==""){
            		$(".warn_content").html("今日没有安排");
            	}else{
            		for(var i=0;i<data.length;i++){
              		tbl+="<p><span>主题</span>：<span>"+data[i].theme+"</span></p><p><span>开始时间</span>：<span>"+data[i].start_date+" "+data[i].start_time+"</span></p><p><span>结束时间</span>：<span>"+data[i].end_date+" "+data[i].end_time+"</span></p><p><span>人员</span>：<span>"+data[i].staff+"</span></p><p><span>说明</span>：<span>"+data[i].instruction +"</span></p>"
            	}
            		$(".warn_content").html(tbl);	
             }
		 }
		 });
		 }
	});
	</script>
	<script type="text/javascript">
		$(function(){
			$(".input_theme").blur(function(){
				$(".formtips").remove();
				if($(this).val()==""){
	                   $(this).after("<span class='formtips'>不能为空</span>")
	               }else{
	                   return;
	               }
			});
			$(".form_submit").click(function(){
				var theme=$(".input_theme").val()
				if(theme==""){
					alert("添加失败");
				}else{
					$(this).prop("type","submit");
				}
			});
		});
	</script>
	<script type="text/javascript">
        $(document).ready(function(){
        	var code = "<%=request.getParameter("code")%>";
        	if(code==0){
        		/* var ch11 = document.getElementById("exit");
                ch11.style.visibility="hidden"; */
                 
                var ch22 = document.getElementById("login");
                ch22.style.visibility="visible";
        	}else if(code==1){
        		/* var ch11 = document.getElementById("exit");
                ch11.style.visibility="visible";
                  */
                var ch22 = document.getElementById("login");
                ch22.style.visibility="hidden";
                
                <%-- var name="<%=request.getParameter("user")%>";
                document.getElementById("user").innerHTML=name; --%>
        	}
        	$("#pt").click(function(){
        	    var name="<%=request.getParameter("user")%>";
         	    location.href="../../jsp/pingtu.jsp?code=1&user="+name;
        	   
        	});
        	
           
        });
    </script>
    <script type="text/javascript">
    	$(function(){
    		$(".form_reset").click(function(){
        		location.href="../../jsp/schedule.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
        	});
    	});
    </script>
     <script type="text/javascript">
    $(function () {
    	$("#showdt").click(function(){
			if($("#info").css("display")=="none"){
				var user="<%=request.getParameter("user")%>";
				
				$.ajax({        			
        			type:"GET",
        		    url:"/Schedule/findPerson.action",
        		    contentType:"application/json;charset=utf-8",  
        		    //我们使用 JSON.stringify() 方法处理json，将其转换为字符串；
        		    data:{
        		    	'user':user
        		    },
        		    dataType:"json",
        		    async:false,
        		    success:function(result){
        		   
        		    	 if(result.code==1){
        		    		
        		    		 var data=result.data;
        		    			        		    		  		    	
//         		    	 $("#da1").val(data.user);
                 		 $("#da3").val(data.name);
                 		 $("#da4").val(data.phone);
                 		 $("#da5").val(data.address);
                 		 
                 		     
        		    	 }else if(result.code==-1){
        		    		 alert("获取用户失败");
        		    	 }      		    	
        		    }        		    
        		});   
				
				$("#info").show();
				
				
			}else{
				$("#info").hide();
			}
		});
		
		$("#save").click(function(){
			
			var user="<%=request.getParameter("user") %>";
     		var name= $("#da3").val();
     		var phone= $("#da4").val();
     		var address=$("#da5").val();
     		
     		var param_data1={                				
  					'user':user,              				
  					'name':name,
    				'phone':phone,
    				'address':address
      	  }
      	  console.log(JSON.stringify(param_data1));
          
          $.ajax({        			
  			type:"GET",
  		    url:"/Schedule/updatePerson.action",
  		    contentType:"application/json;charset=utf-8",  
  		    //我们使用 JSON.stringify() 方法处理json，将其转换为字符串；
  		    data:{'param':JSON.stringify(param_data1)},
  		    dataType:"json",
  		    async:false,
  		    success:function(result){
  		    	 //var  data=JSON.parse(result);//转换成json对象
  		    	 if(result.code==1){
  		    		alert("修改成功");
  		    	 }else{
  		    		 alert("修改失败");
  		    	 }      		    	
  		    }        		    
  		}); //ajax
          
          
		});//save
	});
    </script>
<title>时间安排</title>
</head>
<body>
<div class="container">
			<div class="menu-wrap">
				<p class="pp">
					当前用户:  
					<span style="font-size: 20px" onclick="" id="showdt">&nbsp;&nbsp;&nbsp;<%=request.getParameter("user") %></span>
				</p>
				<div id="info"  style="height: 150px;display: none;" >

				        <span><font  color="#FFFFFF">&nbsp;密&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;&nbsp;</font><input type="password" id="da2" style="margin-left:15px" value="******"></span>
				        <br>
				        <span><font  color="#FFFFFF">&nbsp;姓&nbsp;&nbsp;&nbsp;名:&nbsp;&nbsp;&nbsp;</font>：<input type="text" id="da3" style="margin-left:15px"></span>
				        <br>
				        <span><font  color="#FFFFFF">&nbsp;手&nbsp;&nbsp;&nbsp;机:&nbsp;&nbsp;&nbsp;</font><input type="text" id="da4" style="margin-left:15px"></span>
				        <br>
				        <span><font  color="#FFFFFF">&nbsp;邮&nbsp;&nbsp;&nbsp;箱:&nbsp;&nbsp;&nbsp;</font><input type="text" id="da5" style="margin-left:15px"></span>
				        <br>
				        
				        
				       <button id="save" style="color:black;margin-left:90px;margin-top:10px">保存</button>

				     </div>
				<div  class="out">
					
					<a id="loginout" data-target="" href="main.jsp?code=0"><i class="fa fa-fw fa-newspaper-o"></i><span>退出</span></a>
				</div>
				<nav class="menu">
					<div class="icon-list">
						
					</div>
				</nav>
				<button class="close-button" id="close-button">Close Menu</button>
			</div>
			<button class="menu-button" id="open-button">Open Menu</button>
<div class="header">
	
	<div class="header_nav">
		<ul class="ul1">
			<li>首页</li>
			<li>日程安排
			</li>
			<li>倒计时
			</li>
			 
			<li>益智小游戏
                <ul class="ul2">
                    <li id="pt"><font class="ping" style="color: #fff">拼图</font></li>
                    <li><a href="../../jsp/lianliankan.jsp?code=<%=request.getParameter("code") %>&user=<%=request.getParameter("user") %>" style="margin-left:3px;color:#fff">连连看</a></li>                
                </ul>
            </li>
            <li id="rob">智能机器人</li>

        </ul>
    </div>
    <ul class="register">
        
        <!--  <li id="user"></li>  -->
        <li id="message"><a href="../../jsp/message.jsp?code=<%=request.getParameter("code") %>&user=<%=request.getParameter("user") %>">消息</a></li>
        <!-- <li id="exit"><a href="main.jsp?code=0">退出</a></li> -->
        <li id="login"><a href="../../jsp/login.jsp">登录</a></li>
    </ul>
</div>
<div class="content" style="background: url(../../img/bk.jpg);background-size:cover;">
	<div class="content_left">
		<div class="left_weather">
			<iframe name="weather_inc" src="http://i.tianqi.com/index.php?c=code&id=55"  width="255" height="294" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
		</div>
		<div class="jq22">
			<div id="calendar"></div>
		</div>
	</div>
	<div class="content_right">

		<div class="right_form">
			<form action="${pageContext.request.contextPath }/addSchedule.action" method="POST">
				
				<div class="form_theme">
					<input type="hidden" name="user" value="<%=request.getParameter("user") %>" >
					<label class="label_theme"><span>*</span>主题：</label>
					<input type="text" name="theme" class="input_theme" placeholder="创建一个事件主题">
				</div>
				<div class="form_start">
				<label class="label_start">开始：</label>
				<input type="text" name="start_date" class="start_date" value="<fmt:formatDate value="${now}" pattern="yyyy-MM-dd"/>">
				<select class="select_hour" name="start_time">
					<option value="00">00</option>
					<option value="01">01</option>
					<option value="02">02</option>
					<option value="03">03</option>
					<option value="04">04</option>
					<option value="05">05</option>
					<option value="06">06</option>
					<option value="07">07</option>
					<option value="08">08</option>
					<option value="09">09</option>
					<option value="10">10</option>
					<option value="11">11</option>
					<option value="12">12</option>
					<option value="13">13</option>
					<option value="14">14</option>
					<option value="15">15</option>
					<option value="16">16</option>
					<option value="17">17</option>
					<option value="18">18</option>
					<option value="19">19</option>
					<option value="20">20</option>
					<option value="21">21</option>
					<option value="22">22</option>
					<option value="23">23</option>
					<option value="24">24</option>
				</select><span>:</span>
				<select class="select_minute" name="start_minute">
					<option value="00">00</option>
					<option value="10">10</option>
					<option value="20">20</option>
					<option value="30">30</option>
					<option value="40">40</option>
					<option value="50">50</option>
					<option value="60">60</option>
				</select>
			</div>
				<div class="form_end">
					<label class="label_end">结束：</label>
					<input type="text" name="end_date" class="end_date" value="<fmt:formatDate value="${now}" pattern="yyyy-MM-dd"/>">
					<select class="select_hour" name="end_time">
						<option value="00">00</option>
						<option value="01">01</option>
						<option value="02">02</option>
						<option value="03">03</option>
						<option value="04">04</option>
						<option value="05">05</option>
						<option value="06">06</option>
						<option value="07">07</option>
						<option value="08">08</option>
						<option value="09">09</option>
						<option value="10">10</option>
						<option value="11">11</option>
						<option value="12">12</option>
						<option value="13">13</option>
						<option value="14">14</option>
						<option value="15">15</option>
						<option value="16">16</option>
						<option value="17">17</option>
						<option value="18">18</option>
						<option value="19">19</option>
						<option value="20">20</option>
						<option value="21">21</option>
						<option value="22">22</option>
						<option value="23">23</option>
						<option value="24">24</option>
					</select><span>:</span>
					<select class="select_minute" name="end_minute">
						<option value="00">00</option>
						<option value="10">10</option>
						<option value="20">20</option>
						<option value="30">30</option>
						<option value="40">40</option>
						<option value="50">50</option>
						<option value="60">60</option>
					</select>
				</div>
				<div class="form_par">
					<label class="label_par">人员：</label>
					<input type="text" name="staff" class="input_par" placeholder="添加参与人员">
				</div>
				<div class="form_warn">
					<label class="label_warn">提醒：</label>
					<select class="select_warn"  name="warn">
						<option value="提醒">提醒</option>
						<option value="不提醒">不提醒</option>
					</select>
				</div>
				<div class="form_detail">
					<label class="label_detail">说明：</label>
					<textarea class="input_detail" placeholder="此处添加事件说明" name="instruction"></textarea>
				</div>
				<div class="form_button">
					<input type="button" value="提交" class="form_submit">
					<input type="button" value="返回" class="form_reset">
				</div>
			</form>
		</div>
	</div>
	<div class="div_warn">
	
	<div class="right_warn">
		<h2>提醒安排</h2>
		<div class="warn_content"></div>
	</div>
		<div class="button_warn">
			<p>提</p>
			<p>醒</p>
		</div>
	</div>
</div>
<div class="avgrund-cover"></div>
<aside id="default-popup" class="avgrund-popup">
	<h2>今日安排</h2>
	<div class="detail_content" style="height: 196px;overflow: auto" >
		
	</div>
	<button onClick="javascript:closeDialog();" style="float: right;margin-top:5px">Close</button>

</aside>
</div>
<script src="${pageContext.request.contextPath }/static/js/classie.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/main.js"></script>
</body>
</html>